<template>
  <el-container>
    <div style="text-align: right;width: 100%;font-size: 12px;border: 0;padding: 0 3% 0 0">
      <el-dropdown>
        <i class="el-icon-setting" style="margin-right: 15px"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>查看</el-dropdown-item>
          <el-dropdown-item>
            <span @click="logout">退出</span></el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <span>{{ user.nickname }}</span>
    </div>
  </el-container>
</template>

<script>


export default {
  name: "HomeTop",
  data() {
    return {
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {}
    }
  },
  methods: {
    logout() {
      this.$router.push("/login");
      localStorage.removeItem("user");
      this.$message.success("退出成功")
    }
  },
  mounted() {
  }

}
</script>

<style scoped>

</style>
